/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "RgnDialog.h"
#include "afxcmn.h"
#include "MMachineInfoList.h"
#include "DlgDetails.h"
#include "MKOuiIabList.h"
#include "MKMcast4List.h"
#include "MPortDescriptionList.h"
#include "MPopupMenu.h"

#include "ExportXML.h"

/*! \brief The class behind the Map window
*/
class DlgMap : public CRgnDialog
{
	DECLARE_DYNAMIC(DlgMap)

protected:
	virtual void ResizeChilds(void);

	ExportXML exportXML;

	MPopupMenu popupMenu;
	bool SetPopupMenu(int);
	void ProcessMenuItemCommand(WORD);

	void LaunchHttp(CString);
	void LaunchHttps(CString);
	void LaunchFtp(CString);
	void LaunchTelnet(CString);
	void LaunchSsh(CString);

	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	virtual void OnCancel();

	MMachineInfoList machInfoList;
	CListCtrl listMap;
	CString BuildItemName(MMachineInfo*);
	bool AddItem(MMachineInfo*);
	bool AddGlobalInfo(void);

	afx_msg void OnLvnItemchangedMapList(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnNMRclickMapList(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnLvnColumnclickMapList(NMHDR *pNMHDR, LRESULT *pResult);

	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);

	DECLARE_MESSAGE_MAP()

public:
	DlgMap(CWnd* pParent = NULL);   // standard constructor
	virtual ~DlgMap();

	enum { IDD = IDD_DLG_MAP };

	DlgDetails           *dlgDet;
	MKOuiIabList         *vendorList;
	MKMcast4List         *mcast4List;
	MPortDescriptionList *portDescList;

	bool UpdateInfo(MMachineInfoList*);
	bool UpdateInfoEx(MMachineInfoList*, bool);

	bool ExportAsXml(CString fileNameIn, CString startTimeIn, WorkCfg *cfgIn, LastScanType lstIn);
};
